import axios from "axios"
import { api_urls } from "./urls"

const user_api = {
    login({ username, password }) {
        return axios.post(api_urls.users.login, {username, password});
    },
    logout() {
        return axios.post(api_urls.users.logout, {});
    },
    updatePassword({ password, new_password, renew_password }) {
        return axios.post(api_urls.users.updatePassword, { password, new_password, renew_password });
    },
    pageUser(userReq) {
        return axios.post(api_urls.users.page, userReq);
    },
    updateUser(user) {
        return axios.post(api_urls.users.update, user);
    },
    createUser(user) {
        return axios.post(api_urls.users.create, {...user,id:0});
    },
    deleteUser(userId) {
        return axios.post(api_urls.users.delete, {id: userId});
    }
}


export default user_api;
export const USER_ROLE = {
    MANAGER: 1,
    READONLY: 0,
    SUPER: 2
}